package kk.yiyi.safedesign.gps;

import android.util.Log;

import org.greenrobot.eventbus.EventBus;

import java.io.IOException;

import kk.yiyi.safedesign.base.Constants;
import kk.yiyi.safedesign.base.MessageEvent;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.FormBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

public class GpsService {
    public void gpsAlter(String phone,String ulongitude,String ulatitude)
    {
        OkHttpClient okHttpClient = new OkHttpClient();
        RequestBody requestBody = new FormBody.Builder().add("uphone",phone)
                .add("ulongitude",ulongitude)
                .add("ulatitude",ulatitude)
                .build();
        final Request request = new Request.Builder()
                .url(Constants.GPS_ALTER)
                .post(requestBody)
                .build();
        EventBus.getDefault().post(new MessageEvent("data",ulatitude+ulongitude+"是什么"));
        okHttpClient.newCall(request).enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {
                Log.d("demo","gps失败");
            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                //解析php返回的json数据
                Log.d("demo","gps成功");
            }
        });

    }
}
